package com.hse.network;

import com.hse.network.exceptions.NetworkException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class CoordinatorTester {
    private static final Log log = LogFactory.getLog(CoordinatorTester.class);
    private final Long MAC_ADDRESS = (long) 0;
    private final Short PAN_ID = (short) 12345;

    private ICoordinator coordinator;

    @Before
    public void init() throws InstantiationException {
        log.info("Prepare for test");
        coordinator = new Coordinator(TestConfigurator.PORT_NAME_1, MAC_ADDRESS);
    }

    @After
    public void delete() {
        coordinator.close();
        log.info("Clean up after test");
    }

    @Test
    public void createNetwork() throws NetworkException {
        coordinator.createNetwork(PAN_ID);
    }

    @Test(expected = NetworkException.class)
    public void createNetworkThanCreateAgain() throws NetworkException {
        coordinator.createNetwork(PAN_ID);
        coordinator.createNetwork(PAN_ID);
    }


}
